package com.lottery.ruok.lottrey.dialog;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.activity.LiuhecaiDetailActivity;
import com.lottery.ruok.lottrey.adapter.LiuhecaiTypeAdapter;
import com.lottery.ruok.lottrey.fragment.BaseFragment;
import com.lottery.ruok.lottrey.retrofitModule.response.GetLotteryDetailResponse;

import butterknife.BindView;
import butterknife.ButterKnife;
import ui.NoScrollGridView;

/**
 * Created by ASUS on 2017/8/2.
 */

public class LiuhecaiTypeDialog extends BaseFragment {
    private LiuhecaiDetailActivity liuhecaiDetailActivity;

    @BindView(R.id.grid_view)
    NoScrollGridView gridView;
    @BindView(R.id.close)
    ImageView close;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        liuhecaiDetailActivity = (LiuhecaiDetailActivity)activity;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //自定义对话框样式
        View v = inflater.inflate(R.layout.liuhecai_type_layout, null);

        ButterKnife.bind(this, v);

        getList();

        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getFragmentManager().popBackStack();
            }
        });

        return v;
    }

    private void getList() {
        LiuhecaiTypeAdapter myAdapter = new LiuhecaiTypeAdapter(liuhecaiDetailActivity, getActivity(), this);
        gridView.setAdapter(myAdapter);
    }

    public void setAll(){
        for(GetLotteryDetailResponse.LayoutsBean layoutsBean : liuhecaiDetailActivity.getLotteryDetailResponse.getLayouts()){
            layoutsBean.setSelected("0");
        }
    }
}
